<?php

namespace App\Http\Middleware;

use App\Constants\ErrorResponse;
use Closure;

/**
 * Copyright (C), 2021-2021, lwlCms.
 * FileName: ApiMiddleware.php
 * Description: Api中间件
 *
 * @author lwl
 * @Create Date    2021/5/23 18:54
 * @Update Date    2021/5/23 18:54 By lwl
 * @version v1.0
 */
class UserMiddleware
{
    /**
     * FunctionName：handle
     * Description：api 登录中间件
     * Author：lwl
     * @param $request
     * @param Closure $next
     * @return \Illuminate\Http\JsonResponse|mixed
     */
    public function handle($request, Closure $next)
    {
        //dd(auth('users')->user());
        if (!auth('users')->user()) {
            errorHttpResponse(ErrorResponse::ERROR_NOT_LOGIN);
        }
        return $next($request);
    }
}
